<?php
const reg= /(\d{3})\d*(\d{4})/
let phoneNum = "15612345678"
const res = phoneNum.replace(reg, '$1****$2')
console.log(res) // "156***